package com.xuecheng.mybatis.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class MyBatisPlusConfig {

   //注册mybatis的插件
   @Bean
   public MybatisPlusInterceptor mybatisPlusInterceptor() {
      MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
      //分页的插件
      interceptor.addInnerInterceptor(paginationInnerInterceptor());
      return interceptor;
   }

   //分页的插件配置
   @Bean
   public PaginationInnerInterceptor paginationInnerInterceptor() {
      return new PaginationInnerInterceptor(DbType.MYSQL);
   }
}